$(function () {
    $.ajax({
        type: "get",
        url: ajaxUrl("queryAddress"),
        success: function (result) {
            console.log(result);
            $("#adress").html(template("adressTpl", {
                result: result
            }));
        }
    });

    $("body").on("tap", ".deleteAdress", function () {
        var id = $(this).attr('data-id');
        mui.confirm("确定删除？", "提示", function (res) {
            // console.log(res)
            if (res.index == 0) return;
            $.ajax({
                type: 'post',
                url: ajaxUrl("deleteAddress"),
                data: {
                    id: id
                },
                success: function (result) {
                    if (result.success) {
                        mui.toast("删除成功");
                        setTimeout(function () {
                            location.reload();
                        }, 2000);
                    } else {
                        mui.toast(result.message)
                    }
                }
            })
        })
    })
});